
<div class="container ui-sortable" style="clear:both;">
    <p></p>
    <div class="col-xs-12 col-sm-3">
        {include file="admin@layouts/leftmenu" /}
    </div>
    <div class="col-xs-12 col-sm-9" style="padding-left:2px;">
        <div class="panel panel-default ">
            <div class="panel-header">[tblTitle]</div>
            <div class="panel-body">
        <div class="box box-body" style="margin-bottom: 0px;">

            <form class="form" id="formquery" method="post" >

               <label>用户名：</label>
                <label><input name="username" id="username" class="form-control autowidth" value=""  /></label>
                <!-- <label>条件：</label>
                <label><input name="id" class="form-control autowidth" value=""  /></label>-->


                <label>
                    <input type="hidden" id="pageindex" name="pageindex" value="1">
                    <input type="hidden" id="pagesize" name="pagesize"  value="10">
                    <a id="btnsubmit"  class="btn btn-primary " onclick="getListData(1)" >查询</a>
                    <a id="btnadd" class="btn btn-warning " onclick="popupEdit(0)">添加</a>
                </label>

            </form>


        </div>

		
        <div class="row">
            <div class="col-xs-12">
                <div class="box" style="border-top: 1px solid #d2d6de;">
                    <!-- /.box-header -->
                    <div class="box-body">
                        <table class="table table-border table-bordered table-bg">
                            <thead>
				    <tr>
					<th>编号</th>
				      [loop start]
					<th>[fldTitle]</th>
				      [loop end]^ 
					<th >操作 </th>
				    </tr>
                            </thead>
                            <tbody>
                                 <tr v-cloak :data-id="info.id"  v-for="(info, index) in listdata">
					<td>[[info.id]]</td>
					[loop start]
					<td>[[info.[fldName]]]</td>
					[loop end]^
					<td>
					<div class="ant-row-flex ant-row-flex-center ant-row-flex-middle table-oprator ta-c">
						<a :name="info.id" class="btnedit" onclick="popupEdit(this.name);">
						<i class="fa fa-pencil" title="修改"></i></a>
						<a :name="info.id" class="btndelete" onclick="popupDelete(this.name);">
						<i class="fa fa-trash" title="删除"></i></a>
					</div>
					</td>
				</tr>
                            </tbody>
                        </table>
                    </div>
                    <!-- /.box-body -->
                </div>
                <!-- /.box -->
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
        <!-- 分页 -->
        <div class="pagination ue-clear"></div>

    </div>


</div>

<script>
var VM=new Object();
//ApiHost += "/{subFolder}";

$(function(){
    initPage();
    loadData();
});

//初始化页面
function initPage() {
    VM = new Vue({
        delimiters: ["[[", "]]"],
        el: '#app',
        data: {listdata: []}
    });
    $("#pageindex").val(0);
}

//加载数据
function loadData() {
    getListData(1);
}

//获取列表数据
function getListData(pageindex) {
    if (pageindex == undefined) pageindex = 1;
    $("#pageindex").val(pageindex);
    $("#pagesize").val(Page.pagesize);

    var url = ApiHost + "/{tblName}List";
    var formData = $('#formquery').serialize();
    $.ajax({
        type: "POST",
        url: url,
        dataType: "json",
        data:  formData ,
        error: function (request) {
            ajaxError(request,$(this));
        },
        success: function (result) {
            //console.log(result);
            ajaxSuccess(result, $(this));
            VM.listdata = result.data.rows;
            pagerInit(pageindex, result.data.total);

        }
    });
}

//打开编辑窗口
function popupEdit(id) {
    var url = ApiHost + "/{tblName}Add/?id="+id;
    openLayer(url,"修改");
}

//删除记录
function popupDelete(id) {
    if(confirm("确定要删除此记录吗？删除后不可恢复！")){
        var url = ApiHost + "/{tblName}Delete";
        $.ajax({
                type: "post",
                url: url,
                data: { 
					id:id 
				},
                dataType: "json",
                error: function (request) {
                    ajaxError(request, $(this));
                },
                success: function (result) {
                    ajaxSuccess(result, $(this));
                    var code=result.statecode;
                    if(code==0){
                        //layerAlert("删除成功");
                        layerCallBack();
                    }else{
                        layerAlert("提交失败："+result.message);
                    }
                }
            }
        );

    }

}

//回调函数
function layerCallBack() {
    setTimeout('loadData()',200);

}
</script>




